package com.artron.mediaartron.util;

import android.text.TextUtils;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-11-08.
 */

public class RegexUtils {

    public static final String TELPHONE_REGEX = "^1[34578][0-9]\\d{8}$";

    public static boolean isTelPhoneNum(String number) {
        return !TextUtils.isEmpty(number) && number.matches(TELPHONE_REGEX);
    }

    public static String phoneNumber(String phone) {

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < phone.length(); i++) {
            char charAt = phone.charAt(i);
            if (i >= 3 && i <= 6) {
                sb.append("*");
            } else {
                sb.append(charAt);
            }
        }
        return sb.toString();
    }
}
